package com.hy.erp.inventory.service;

import java.util.List ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.warehousing.IInspectionStyleDao;
import com.hy.erp.inventory.pojo.interfaces.warehousing.IInspectionStyle;
import com.hy.erp.inventory.pojo.warehousing.InspectionStyle;
import com.hy.erp.inventory.service.interfaces.IInspectionStyleService;

public class InspectionStyleService extends AbstractBusinessService < IInspectionStyle > implements IInspectionStyleService
{

	@ Override
	public boolean addInspectionStyle (
										IInspectionStyle inspectionStyle )
	{






		if ( null == inspectionStyle)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


			IInspectionStyleDao inspectionStyleDao =
			                       ( IInspectionStyleDao ) this
			                                          .getDao ( IInspectionStyle.class ) ;
			
		
			return inspectionStyleDao
			                .persist ( inspectionStyle ) ;
		}
		
	
	
	
	
	
	
	}

	@ Override
	public boolean modifyInspectionStyle (
											IInspectionStyle inspectionStyle )
	{






		if ( ( null == inspectionStyle )
		     || ( null == inspectionStyle
		                                .getIdentifier ( ) )
		     || ( inspectionStyle
		                        .getIdentifier ( )
		                        .trim ( )
		                        .length ( ) == 0 ) )
		{
			return true ;
		}
		else
		{


			IInspectionStyleDao inspectionStyleDao =
                ( IInspectionStyleDao ) this
                                   .getDao ( IInspectionStyle.class ) ;

				
			if ( null == inspectionStyle )
			{
				throw new ArchitectureFoundationException  (
				                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			
			
			return ( inspectionStyleDao
			                  .merge ( inspectionStyle ) != null ) ;
		}
	
	
	
	
	
	
	
	}

	@ Override
	public Integer removeInspectionStyle (
											String [ ] inspectionStyleIds )
	{





		if ( ( null == inspectionStyleIds )
			     || ( inspectionStyleIds.length == 0 ) )
		{
			return new Integer (
			                     0 ) ;
		}
		else
		{
			
		IInspectionStyleDao inspectionStyleDao =
            ( IInspectionStyleDao ) this
                               .getDao ( IInspectionStyle.class ) ;
			return inspectionStyleDao
			                .remove ( inspectionStyleIds ) ;
		}
		
	
	
	
	
	
	}

	@ Override
	public String [ ] addInspectionStyle (
											Object [ ] inspectionStyle )
	{

		if ( null == inspectionStyle)
		{
			return null ;
		}
		
		else
		{

			IInspectionStyleDao inspectionStyleDao =
			                       ( IInspectionStyleDao ) this
			                                          .getDao ( IInspectionStyle.class ) ;

			InspectionStyle[] inspectionStyles=new InspectionStyle[inspectionStyle.length];
						for(int i=0;i<inspectionStyle.length;i++)
						{
							InspectionStyle inspectionStyle2=( InspectionStyle ) inspectionStyle[i];
							inspectionStyles[i]=inspectionStyle2;
						}
						return inspectionStyleDao
						                .persist ( inspectionStyles ) ;
		
		
		}
		
	
	
	
	
	
	
	
	}

	@ Override
	public List < IInspectionStyle > getAllInspectionStyle ( )
	{
		IInspectionStyleDao inspectionStyleDao =
            ( IInspectionStyleDao ) this
                               .getDao ( IInspectionStyle.class ) ;
			return inspectionStyleDao
			                .find ( ) ;
	}

	@ Override
	public String [ ] modifyInspectionStyle (
												Object [ ] inspectionStyle )
	{


		if ( null == inspectionStyle)
		{
			return null ;
		}
		
		else
		{

			IInspectionStyleDao inspectionStyleDao =
			                       ( IInspectionStyleDao ) this
			                                          .getDao ( IInspectionStyle.class ) ;

			InspectionStyle[] inspectionStyles=new InspectionStyle[inspectionStyle.length];
						for(int i=0;i<inspectionStyle.length;i++)
						{
							InspectionStyle inspectionStyle2=( InspectionStyle ) inspectionStyle[i];
							inspectionStyles[i]=inspectionStyle2;
						}
						return inspectionStyleDao
						                .merge  ( inspectionStyles ) ;
		
		
		}
	
	
	}

}
